home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / SRCH_FIL.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  3KB  |  118 lines

  1. ;    DESC:    search for the first of a set of matching filenames  V1.00
  2. ;
  3. ;    ***    CX must be loaded with the appropriate file attribute
  4. ;        to search on (1:read only,2:hidden file,
  5. ;         4:system file,8:volume label,10H:sub-directory,
  6. ;         20H:archived file).                              ***
  7. ;
  8. ;    IN:    *{SEG_VAL} segment and
  9. ;        *{OFFSET} offset of search string
  10. ;    OUT:    *{TIME} time file last written
  11. ;        *{DATE} date file last written
  12. ;        *{SIZE_LO} low word of file size
  13. ;        *{SIZE_HI} high word of file size
  14. ;        *{OUT_SEG} segment and
  15. ;        *{OUT_OFF} offset of first matching filename
  16. ;        *{LENGTH} length of filename found, 0 if not found
  17. ;    SAMPLE:    SRCH_FIL,<SEG_VAL,OFFSET>,
  18. ;                 <TIME,DATE,SIZE_LO,SIZE_HI,OUT_SEG,OUT_OFF,LENGTH>
  19. ;    ################################################################
  20.  
  21. SRCH_FID Segment Para Common 'DATA'
  22. TRANSFER    DB    80H DUP(0)        ;temporary data transfer area.
  23. THIRTY        DW    30            ;value of number thirty.
  24. SEGER        DW    0            ;segment and offset of stored
  25. OFFER        DW    0            ;old data area.
  26. SRCH_FID Ends
  27.  
  28.  
  29.     Extrn    PUSHALL:Near
  30.     Extrn    POPALL:Near
  31.     Extrn    GET_DSK:Near
  32.     Extrn    SET_DSK:Near
  33.  
  34. SRCH_FIC    Segment
  35.     Assume    CS:SRCH_FIC,DS:SRCH_FID
  36.     Public    SRCH_FIL
  37.  
  38.                         ;notice.
  39.     DB    'SRCH_FIL - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  40.  
  41. SRCH_FIL    Proc    Near
  42.     Call    PUSHALL                ;save registers.
  43.  
  44.     Mov    AX,SRCH_FID            ;load workarea.
  45.     Mov    DS,AX
  46.  
  47. SRCHR:    Call    GET_DSK                ;find current DTA.
  48.  
  49.     Pop    SEGER                ;save DTA location.
  50.     Pop    OFFER
  51.  
  52.     Push    DS                ;setup new DTA.
  53.     Mov    AX,OFFSET TRANSFER
  54.     Push    AX
  55.     Call    SET_DSK
  56.  
  57.     Mov    AX,4E00H            ;continue search.
  58.  
  59.     Pop    DX                ;recover filename segment
  60.     Pop    DS                ;and offset.
  61.  
  62. TOP:    Push    DS                ;save filename info.
  63.     Push    DX
  64.  
  65.     Int    21H
  66.  
  67.     Mov    AH,0                ;save search results.
  68.     Mov    DX,AX
  69.  
  70.     Mov    AX,SRCH_FID            ;restore workarea.
  71.     Mov    DS,AX
  72.  
  73.     Mov    BP,30                ;load file area offset.
  74.  
  75.     Cmp    DX,0                ;see if filename was there.
  76.     Jnz    REST
  77.  
  78. ENDLOC:    Mov    AX,DS:WORD PTR[BP]        ;determine length of filename.
  79.     Cmp    AL,0
  80.     Jz    REST
  81.     Inc    BP
  82.     Jmp    ENDLOC
  83.  
  84. REST:    Sub    BP,THIRTY            ;length of filename.
  85.     Jz    OK
  86.  
  87.     Cmp    CL,DS:BYTE PTR[21]        ;check that files match
  88.     Jz    OK                ;search attribute.
  89.  
  90.     Pop    DX                ;if not a good file then
  91.     Pop    DS                ;search for next match.
  92.  
  93.     Mov    AX,4F00H            ;continue search.
  94.     Jmp    TOP
  95.  
  96. OK:    Pop    AX                ;discard filename info.
  97.     Pop    AX
  98.  
  99.     Push    BP                ;return filename length.
  100.     Push    THIRTY                ;offset and
  101.     Push    DS                ;segment of filename.
  102.     Push    DS:WORD PTR[28]            ;high word of file size.
  103.     Push    DS:WORD PTR[26]            ;low word of file size.
  104.     Push    DS:WORD PTR[24]            ;time file last written.
  105.     Push    DS:WORD PTR[22]            ;date file last written.
  106.  
  107.     Push    SEGER                ;restore old DTA.
  108.     Push    OFFER
  109.     Call    SET_DSK
  110.  
  111.     Call    POPALL                ;restore registers.
  112.     Ret
  113.  
  114. SRCH_FIL    Endp
  115.  
  116. SRCH_FIC    Ends
  117.     End
  118.